local kenfeng = fk.CreateSkill{
    name = "wk_heg__kenfeng",
}

Fk:loadTranslationTable{
  ["wk_heg__kenfeng"] = "垦丰",
  [":wk_heg__kenfeng"] = "其他角色的结束阶段，你可令一名手牌数不大于你的角色选择是否将一张♣牌置于牌堆底并摸两张牌，若如此做，其展示以此法获得的所有牌并将其中的♣牌交给一名其距离为1的角色。",
  ["#wk_heg__kenfeng_choose"] = "垦丰：你可以选择一名手牌数不大于体力值的角色，然后其可以将一张 梅花 牌置于牌堆底并摸两张牌",
  ["#wk_heg__kenfeng_card"] = "垦丰：你可以将一张 梅花 牌置于牌堆底，然后摸两张牌",
  ["#wk_heg__kenfeng_give"] = "垦丰：选择一名与你距离为1的角色，将以此法获得的所有 梅花 牌交给其",

  ["$wk_heg__kenfeng1"] = "",
  ["$wk_heg__kenfeng2"] = "",
}

kenfeng:addEffect(fk.EventPhaseStart,{
    anim_type = "offensive",
    can_trigger = function(self, event, target, player, data)
      return player:hasSkill(kenfeng.name) and player ~= target and target.phase == Player.Finish
      and table.find(player.room.alive_players, function (p) return p:getHandcardNum() <= player:getHandcardNum() end)
    end,
    on_use = function(self, event, target, player, data)
      local room = player.room
      local targets = table.filter(room.alive_players, function (p) return p:getHandcardNum() <= player:getHandcardNum() end)
      if #targets > 0 then
      local tos = room:askToChoosePlayers(player,{
        targets = targets,
        min_num = 1,
        max_num = 1,
        skill_name = kenfeng.name,
        prompt = "#wk_heg__kenfeng_choose",
      })
      if #tos > 0 then
        local to = tos[1]
        local cards = room:askToCards(to,{
            min_num = 1,
            max_num = 1,
            include_equip = true,
            skill_name = kenfeng.name,
            prompt = "#wk_heg__kenfeng_card",
            pattern = ".|.|club",
            cancelable = true,
        })
        if #cards > 0 then
          room:moveCards({
            ids = cards,
            from = to,
            toArea = Card.DrawPile,
            moveReason = fk.ReasonJustMove,
            skillName = kenfeng.name,
            proposer = to,
            drawPilePosition = -1,
          })
          local draw_cards = to:drawCards(2, kenfeng.name)
          to:showCards(draw_cards)
          local need_give = {}
          for _, cid in ipairs(draw_cards) do
            local card = Fk:getCardById(cid)
            if card.suit == Card.Club then
              table.insertIfNeed(need_give, cid)
            end
          end
          local give_aim = table.filter(room.alive_players, function (p) return to:distanceTo(p) == 1 end)
          if #need_give > 0 and #give_aim > 0 then
            local give_tos = room:askToChoosePlayers(to, {
                targets = give_aim,
                min_num = 1,
                max_num = 1,
                prompt = "#wk_heg__kenfeng_give",
                skill_name = kenfeng.name,
                cancelable = false,
            })
            local give_to = give_tos[1]
            room:obtainCard(give_to, need_give, false, fk.ReasonGive)
            end
          end
        end
      end
    end,
})

return kenfeng